package cn.edu.ctbu.datajpa03.api;

import cn.edu.ctbu.datajpa03.domain.Student;
import cn.edu.ctbu.datajpa03.service.StudentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/api")
public class StudentApiController {
/*controller是表现层，表现层要调用业务逻辑层StudentService*/
/*@Autowired:不需要亲自new，只需要自动包裹和自动注入就可以了*/
        @Autowired
        private StudentService studentService;

        @GetMapping("/student/list")
        public List<Student> list(){
            return studentService.findAll();
        }


}
